<template>
	<view class="home">
		<!-- 首页顶部搜索区域 -->
		<view class="home-header">
			<view class="header-search">
				<u-input placeholder="输入医生姓名/医院名称进行搜索" v-model="name" border="surround" fontSize="16rpx"
					shape="circle">
					<template slot="suffix">
						<u-button type="success" size="mini" shape="circle" color="#54b6ab"
							@click="getInSearchDoctor(name)">搜
							索</u-button>
					</template></u-input>
			</view>
		</view>
		<!-- 首页线上预约区域 -->
		<view class="home-reservation">
			<!-- 列表区域 -->
			<view class="reservation-list">

				<view v-if="list.length===0">
					<u-empty mode="search" icon="../static/image/search.png">
					</u-empty>
				</view>


				<view class="list-box" v-for="item in list" :key="item.id" 
					v-if="list.length>0">
					<image src="@/static/image/doctor.jpg" mode=""></image>
					<view class="list-count">
						<text class="title">
							<text style="font-weight: bold;color: #000;">
								{{item.realName}}
							</text>
							<text class="title" style="margin-left: 15rpx;">
								{{item.occupationTitle}}
							</text>
						</text>
						<text class="title" style="color: #000;">{{item.hospital}} | {{item.administrativeOffice}}</text>
						<u--text :lines="2" size="10" type="info" :text="'擅长：'+item.personalExpertise"></u--text>
					</view>
					<view class="list-btn">
						<text class="money">{{item.consultExpense==0?'免费':'¥'+item.consultExpense}}</text>
						<u-button type="success" size="mini" shape="circle" color="#54b6ab" @click="getInDoctorDetails(item.id)">立即预约</u-button>
					</view>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				name: '',
				list: []
			};
		},
		onLoad(option) {
			this.name = option.name
			this.getInSearchDoctor(this.name)
		},
		methods: {
			//医生主页
			getInDoctorDetails(id) {
				uni.navigateTo({
					url: '/pages/doctorDetails?doctorId='+id
				})
			},
			//查询医生列表
			async getInSearchDoctor(name) {
				let obj = {
					searchCriteria: name
				}
				const {
					data
				} = await uni.$http.post('/patient-doctor/homeSearch', obj)
				if (data.code === 200) {
					this.list = data.data
				}
			}
		}
	}
</script>

<style lang="scss">
	.home {
		width: 100%;
		height: 100%;
		background-color: #f2f2f2;
		overflow: auto;

		.home-header {
			width: 100%;
			background-color: #fff;
			padding: 10rpx 2.5%;
			box-sizing: border-box;

			.header-nav {
				width: 100%;
				margin-bottom: 10rpx;
				display: flex;
				align-items: center;

				image {
					width: 40rpx;
					height: 40rpx;
					margin-right: 10rpx;
				}
			}

			.header-search {
				width: 100%;
			}
		}

		.home-reservation {
			margin: 0 auto;
			width: 100%;
			border-radius: 20rpx;
			padding: 20rpx;
			box-sizing: border-box;

			.reservation-list {
				width: 100%;

				.list-box {
					width: 100%;
					padding: 20rpx;
					box-sizing: border-box;
					background-color: #fff;
					margin-bottom: 20rpx;
					border-radius: 20rpx;
					display: flex;
					align-items: stretch;
					justify-content: space-between;

					image {
						width: 100rpx;
						height: 100rpx;
					}

					.list-count {
						width: calc(100% - 300rpx);
						display: flex;
						flex-direction: column;

						.title {
							font-size: 26rpx;
							color: #999;
							margin-bottom: 20rpx;
							box-sizing: border-box;
						}

						.count {
							word-break: break-all;
							text-overflow: ellipsis;
							display: -webkit-box;
							-webkit-box-orient: vertical;
							-webkit-line-clamp: 2;
							overflow: hidden;
							font-size: 20rpx;
						}
					}

					.list-btn {
						width: 140rpx;
						display: flex;
						flex-direction: column;
						align-items: flex-end;
						justify-content: space-around;

						.money {
							color: red;
							font-weight: bold;
							font-size: 26rpx;
						}
					}
				}
			}
		}



	}
</style>